#include "Database.h"

Database* Database::m_instance = 0;

Database::Database(){}
Database::~Database()
{
	for(list<BaseController*>::iterator i = m_ctrlList.begin(); i != m_ctrlList.end(); i++)
	{
		if( *i != 0)
		{
			delete *i;
			*i = 0;
		}
	}
}


Database& Database::getInstance()
{
	if(m_instance == 0)
		m_instance = new Database();

	return *m_instance;
}

void Database::close()
{
	if(m_instance != 0)
	{
		delete m_instance;
		m_instance = 0;
	}
}

void Database::addController(BaseController* ctrl)
{
	m_ctrlList.push_back(ctrl);
}

//void Database::onChange()
//{
//	for(list<BaseController*>::iterator it = m_ctrlList.begin(); it != m_ctrlList.end(); it++)
//		(*it)->onChange();
//}